fit ( func, param, x, y = 0, wd = 1, we = 1, partol = 1, maxit = 50, ifixp = 1, ifixx = 1, taufac = 1, sstol = 1, sclp = 1, scld = 1, report = 0 ) Types: func Stmt param double[] x double[] y double[] wd double[] we double[] partol double maxit int ifixp int[] ifixx int[] taufac double sstol double sclp double[] scld double[] report int
double[] (fit values of the parameters)
[(x; param1, param2,....)->y : y=f (x, param1, param2,...);].
Here param1, param2,... are the adjustable parameters of the model. The data points are given by the arrays x and y. The start points of the parameters param1, param2,... are given by the array param. wd (type double array) sets the weights the errors of the x-values while we sets the weights the errors of the y-values, partol is the stopping tolerance for parameter convergence, maxit specifies the maximum of iterations allowed, ifixp is an integer array determing the parameters which are to be treated as fixed, the integer array ifixx marks the x-values which are treated as without errors, the single value taufac represents the trust region radius, sstol specifies the stopping tolerance sum of squares convergence, sclp is a double array which scales the parameters, the array scld scales the errors of the x-values and at last the keyword report determines if a report of the fitting algorithm is to be generated.
The adjustable parameter in this example are the variables mu, b, g and the funtion is 2 f(x; mu, b, g)=mu + b*(exp(g*x)-1) >double[] f(double x[], double mu, double b, double g) { >return mu+b*pow(exp(g*x)-1,2); } Function f defined >beta={1500,-50,-0.1}; >x={0,0,5,7,7.5,10,16,26,30,34,34.5,100}; >y={1265,1263.6,1258,1254,1253,1249.8,1237,1218,1220.6,1213.8,1215.5,1212}; >p=fit([(x; mu, b, g)->y : y=f(x,mu, b, g);], beta, x, y); Message: sum of squares convergence >print(p); <dblarr> 1264.654804 -54.01840867 -0.08784971578